var app = getApp();

Page({
    data: {
       region: [],
        starMoney:3,
        star:0,
        starMap: [
            '非常差',
            '差',
            '一般',
            '好',
            '非常好',
        ],
        agentId:''
    },
    onLoad: function(n) {
        var self = this,agentId=n.typeId;
        self.setData({
           agentId:agentId
        })
    },
       //用户名和密码输入框事件
  userNameInput:function(e){
    this.setData({
      userN:e.detail.value
    })
  },
  userPhoneInput:function(e){
    this.setData({
      passW:e.detail.value
    })
  },
  userShopInput:function(e){
    this.setData({
      shopname:e.detail.value
    })
  },
  userAddressInput:function(e){
    this.setData({
      address:e.detail.value
    })
  },
  userBeizhuInput:function(e){
    this.setData({
      beizhu:e.detail.value
    })
  },
  bindRegionChange: function(a) {
        console.log("picker发送选择改变，携带值为", a.detail.value), this.setData({
            region: a.detail.value
        });
    },
    getform: function(o) {
        console.log(o), app.util.request({
            url: "entry/wxapp/Formid",
            data: {
                openid: wx.getStorageSync("openid"),
                formid: o
            },
            success: function(o) {}
        });
    },
    adduser:function(){
        var self = this;
        app.util.request({
            url: "entry/wxapp/Add_hzuser",
            data: {
                shopname:self.data.shopname,
                username:self.data.userN,
                mobile:self.data.passW,
                city:self.data.region,
                address:self.data.address,
                yixiang:self.data.star,
                beizhu:self.data.beizhu,
                goodsid:self.data.agentId

            },
            success: function(o) {
                 wx.showToast({
                        title: "添加成功!"
                    });
               setTimeout(function(){
                    wx.navigateTo({
                            url: "/hyb_jianzhi/ccus/ccus"
                        });
                }, 1000);
            }
        });
    },
    myStarChoose:function(e){
        let star = parseInt(e.target.dataset.star) || 0;
        this.setData({
            star: star,
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});